package se.sll.service.catalogue.common;

import org.junit.Before;

/**
 * Base class for DAO test cases.
 * 
 * @author Christer Palm, Nogui
 */
public class JpaFacadeTestCase<TDao extends AbstractJpaFacade<?>> extends JpaTestCase {
    private final Class<TDao> klass;
    protected TDao dao;

    protected JpaFacadeTestCase(Class<TDao> klass, String persistenceUnit, String initScript) {
        super(persistenceUnit, initScript);
        this.klass = klass;
    }

    protected JpaFacadeTestCase(Class<TDao> klass, String persistenceUnit) {
        this(klass, persistenceUnit, null);
    }

    @Before
    public void initDao() throws InstantiationException, IllegalAccessException {
        dao = klass.newInstance();
        dao.setEntityManager(entityManager);
    }
}
